//
//  NewsTableViewCell.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/4.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "NewsTableViewCell.h"

@implementation NewsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self masLayoutSubview];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}


//- (UIView *)typeView
//{
//    if(!_typeView)
//    {
//        UIView *superView = self;
//        _typeView = [[UIView alloc]init];
//        [superView addSubview:_typeView];
//        _typeView.backgroundColor = rgba(251,74,79,1);
//    }
//    return _typeView;
//}
//- (UILabel *)typeLabel
//{
//    if(!_typeLabel)
//    {
//        UIView *superView = self;
//        _typeLabel = [[UILabel alloc]init];
//        [superView addSubview:_typeLabel];
//        _typeLabel.font = fontWithSize(16);
//        [_typeLabel setTextColor:rgba(251,74,79,1)];
//    }
//    return _typeLabel;
//}

- (UIButton *)typeButton
{
    if(!_typeButton)
    {
        UIView *superView = self.contentView;
        _typeButton = [[UIButton alloc]init];
        [superView addSubview:_typeButton];
        [_typeButton setTitle:@"通知" forState:UIControlStateNormal];
        [_typeButton setTitle:@"报警" forState:UIControlStateSelected];
        [_typeButton setImage:imageWithName(@"btn_news_nor") forState:UIControlStateNormal];
        [_typeButton setImage:imageWithName(@"btn_news_pre") forState:UIControlStateSelected];
        [_typeButton setTitleColor:rgba(143,157,189,1) forState:UIControlStateNormal];
        [_typeButton setTitleColor:rgba(251,74,79,1) forState:UIControlStateSelected];
        [_typeButton.titleLabel setFont:fontWithSize(17)];
        [_typeButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:10];
        _typeButton.userInteractionEnabled = NO;
    }
    return _typeButton;
}

- (UILabel *)dateLabel
{
    if(!_dateLabel)
    {
        UIView *superView = self;
        _dateLabel = [[UILabel alloc]init];
        [superView addSubview:_dateLabel];
        [_dateLabel setFont:fontWithSize(13)];
        [_dateLabel setTextColor:rgba(143,157,189,1)];
    }
    return _dateLabel;
}
- (UIView *)contentBgView
{
    if(!_contentBgView)
    {
        UIView *superView = self;
        _contentBgView = [[UIView alloc]init];
        [superView addSubview:_contentBgView];
        _contentBgView.layer.cornerRadius = 2;
        _contentBgView.backgroundColor = rgba(27,44,81,1);
    }
    return _contentBgView;
}
- (UILabel *)contentLabel
{
    if(!_contentLabel)
    {
        UIView *superView = self.contentBgView;
        _contentLabel = [[UILabel alloc]init];
        [superView addSubview:_contentLabel];
        [_contentLabel setFont:fontCommonSize];
        [_contentLabel setTextColor:[UIColor whiteColor]];
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}


- (void)masLayoutSubview
{
    __weak UIView *superView = self.contentView;
    
    [self.typeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(40));
        make.left.mas_equalTo(superView.mas_left);
        make.width.mas_equalTo(60);
    }];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.typeButton.mas_centerY);
        make.left.mas_equalTo(self.typeButton.mas_right).with.offset(px1080Width(50));
    }];
    
    [self.contentBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.typeButton.mas_bottom).with.offset(px1920Height(20));
        make.left.right.mas_equalTo(superView);
        make.height.mas_equalTo(px1920Height(180));
//        make.bottom.mas_equalTo(superView.mas_bottom).with.offset(-px1920Height(20));
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentBgView.mas_top).with.offset(px1920Height(20));
        make.bottom.mas_equalTo(self.contentBgView.mas_bottom).with.offset(-px1920Height(20));
        make.left.mas_equalTo(self.contentBgView.mas_left).with.offset(px1920Height(40));
        make.right.mas_equalTo(self.contentBgView.mas_right).with.offset(-px1920Height(40));

    }];
}

@end
